From 251e6d181bbe595b745dfd883629c67dd3349cf1 Mon Sep 17 00:00:00 2001 From: "vh249@arcadians.cl.cam.ac.uk" Date: Wed, 31 Aug 2005 10:39:53 +0000 Subject: [PATCH] extends xm info with xen version and various others information. exports version hypercall to userspace Signed-off-by: Vincent Hanquez --- tools/libxc/xc_private.c | 5 ++++ tools/libxc/xc_private.h | 11 +++++++++ tools/libxc/xenctrl.h | 3 +++ tools/python/xen/lowlevel/xc/xc.c | 40 +++++++++++++++++++++++++++++++ tools/python/xen/xend/XendNode.py | 13 ++++++++-- xen/common/kernel.c | 21 ++++++++++++++++ xen/include/public/version.h | 9 +++++++ 7 files changed, 100 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 7d6aaae059..4cbfa2f1f2 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -422,3 +422,8 @@ int xc_dom0_op(int xc_handle, dom0_op_t *op) { return do_dom0_op(xc_handle, op); } + +int xc_version(int xc_handle, int cmd, void *arg) +{ + return do_xen_version(xc_handle, cmd, arg); +} diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index 802ea47201..0e20d2db59 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -59,6 +59,17 @@ static inline int do_xen_hypercall(int xc_handle, (unsigned long)hypercall); } +static inline int do_xen_version(int xc_handle, int cmd, void *dest) +{ + privcmd_hypercall_t hypercall; + + hypercall.op = __HYPERVISOR_xen_version; + hypercall.arg[0] = (unsigned long) cmd; + hypercall.arg[1] = (unsigned long) dest; + + return do_xen_hypercall(xc_handle, &hypercall); +} + static inline int do_dom0_op(int xc_handle, dom0_op_t *op) { int ret = -1; diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index caeee56226..16a6339a5e 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -23,6 +23,7 @@ typedef int64_t s64; #include #include #include +#include #include #include #include @@ -497,6 +498,8 @@ long xc_get_tot_pages(int xc_handle, u32 domid); /* Execute a privileged dom0 operation. */ int xc_dom0_op(int xc_handle, dom0_op_t *op); +int xc_version(int xc_handle, int cmd, void *arg); + /* Initializes the store (for dom0) remote_port should be the remote end of a bound interdomain channel between the store and dom0. diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 33f40e250e..ad7716b76b 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -707,6 +707,39 @@ static PyObject *pyxc_physinfo(PyObject *self, "cpu_khz", info.cpu_khz); } +static PyObject *pyxc_xeninfo(PyObject *self, + PyObject *args, + PyObject *kwds) +{ + XcObject *xc = (XcObject *)self; + xen_extraversion_t xen_extra; + xen_compile_info_t xen_cc; + xen_changeset_info_t xen_chgset; + long xen_version; + + xen_version = xc_version(xc->xc_handle, XENVER_version, NULL); + + if ( xc_version(xc->xc_handle, XENVER_extraversion, &xen_extra) != 0 ) + return PyErr_SetFromErrno(xc_error); + + if ( xc_version(xc->xc_handle, XENVER_compile_info, &xen_cc) != 0 ) + return PyErr_SetFromErrno(xc_error); + + if ( xc_version(xc->xc_handle, XENVER_changeset, &xen_chgset) != 0 ) + return PyErr_SetFromErrno(xc_error); + + return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s}", + "xen_major", xen_version >> 16, + "xen_minor", (xen_version & 0xffff), + "xen_extra", xen_extra, + "xen_changeset", xen_chgset, + "cc_compiler", xen_cc.compiler, + "cc_compile_by", xen_cc.compile_by, + "cc_compile_domain", xen_cc.compile_domain, + "cc_compile_date", xen_cc.compile_date); +} + + static PyObject *pyxc_sedf_domain_set(PyObject *self, PyObject *args, PyObject *kwds) @@ -1089,6 +1122,13 @@ static PyMethodDef pyxc_methods[] = { "Returns [dict]: information about the hardware" " [None]: on failure.\n" }, + { "xeninfo", + (PyCFunction)pyxc_xeninfo, + METH_VARARGS, "\n" + "Get information about the Xen host\n" + "Returns [dict]: information about Xen" + " [None]: on failure.\n" }, + { "shadow_control", (PyCFunction)pyxc_shadow_control, METH_VARARGS | METH_KEYWORDS, "\n" diff --git a/tools/python/xen/xend/XendNode.py b/tools/python/xen/xend/XendNode.py index 75b454fbb8..859d39d31f 100644 --- a/tools/python/xen/xend/XendNode.py +++ b/tools/python/xen/xend/XendNode.py @@ -46,7 +46,7 @@ class XendNode: return self.xc.bvtsched_global_get() def info(self): - return self.nodeinfo() + self.physinfo() + return self.nodeinfo() + self.physinfo() + self.xeninfo() def nodeinfo(self): (sys, host, rel, ver, mch) = os.uname() @@ -65,7 +65,16 @@ class XendNode: ['free_memory', pinfo['free_pages']/256]] return info - + def xeninfo(self): + xinfo = self.xc.xeninfo() + return [['xen_major', xinfo['xen_major']], + ['xen_minor', xinfo['xen_minor']], + ['xen_extra', xinfo['xen_extra']], + ['xen_changeset', xinfo['xen_changeset']], + ['cc_compiler', xinfo['cc_compiler']], + ['cc_compile_by', xinfo['cc_compile_by']], + ['cc_compile_domain', xinfo['cc_compile_domain']], + ['cc_compile_date', xinfo['cc_compile_date']]] def instance(): global inst diff --git a/xen/common/kernel.c b/xen/common/kernel.c index d8af717b62..d36dd8d580 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -110,6 +110,27 @@ long do_xen_version(int cmd, void *arg) return -EFAULT; return 0; } + + case XENVER_capabilities: + { + struct xen_capabilities_info info; + + /* FIXME */ + info.arch = 0; + info.pae = 0; + if ( copy_to_user(arg, &info, sizeof(info)) ) + return -EFAULT; + return 0; + } + + case XENVER_changeset: + { + xen_changeset_info_t chgset; + safe_strcpy(chgset, XEN_CHANGESET); + if ( copy_to_user(arg, chgset, sizeof(chgset)) ) + return -EFAULT; + return 0; + } } return -ENOSYS; diff --git a/xen/include/public/version.h b/xen/include/public/version.h index d9cc66b5d2..d369867416 100644 --- a/xen/include/public/version.h +++ b/xen/include/public/version.h @@ -28,4 +28,13 @@ typedef struct xen_compile_info { char compile_date[32]; } xen_compile_info_t; +#define XENVER_capabilities 3 +typedef struct xen_capabilities_info { + int pae; + int arch; +} xen_capabilities_info_t; + +#define XENVER_changeset 4 +typedef char xen_changeset_info_t[64]; + #endif /* __XEN_PUBLIC_VERSION_H__ */ -- 2.30.2